<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;

class OpenapiLog extends Model
{
    use HasFactory;
    protected $fillable = [
        'interface', 'parameter', 'result', 'method'
    ];

    protected $casts = [
        'parameter' => 'json',
        'result' => 'json',
    ];

    public static function addLog($interface, $parameter, $result, $method)
    {
        $insert_data = [
            'interface' => $interface,
            'parameter' => $parameter,
            'result' => $result,
            'method' => $method
        ];
        return static::create($insert_data);
    }
}
